package main

import (
	"os"
	"fmt"
)
func main() {
	file, err := os.OpenFile("D:/dev/golang/dadi/test.txt", os.O_CREATE | os.O_RDWR | os.O_APPEND, 0666)
	defer file.Close()
	if (err != nil) {
		fmt.Println("open file error:", err)
		return
	}
	// 注意这样写是写到了文件的最前面
	for i := 0; i < 10; i++ {
		file.WriteString("直接写入字符串数据" + strconv.Itoa(i) + "\r\n")	
	}
}